//
//  HGOrderCenterVC.m
//  RedWinMall
//
//  Created by HeDianZhao on 2018/8/1.
//  Copyright © 2018年 HeDianZhao. All rights reserved.
//

#import "HGOrderCenterVC.h"
#import "LTScrollView-Swift.h"
#import "HGOrderListVC.h"

@interface HGOrderCenterVC ()<LTAdvancedScrollViewDelegate>

@property(copy, nonatomic) NSArray <UIViewController *> *viewControllers;
@property(copy, nonatomic) NSArray <NSString *> *titles;
@property(strong, nonatomic) LTLayout *layout;
@property(strong, nonatomic) LTAdvancedManager *managerView;

@end

@implementation HGOrderCenterVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setupSubViews];
}


-(void)setupSubViews {
    
    self.title = @"订单中心";
    
    [self.view addSubview:self.managerView];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:(UIBarButtonItemStyleDone) target:self action:@selector(pop)];
}

- (void)pop {
    [self.navigationController popToRootViewControllerAnimated:YES];
}

-(LTAdvancedManager *)managerView {
    if (!_managerView) {
        _managerView = [[LTAdvancedManager alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, kScreenHeight-kNavigationHeight) viewControllers:self.viewControllers titles:self.titles currentViewController:self layout:self.layout headerViewHandle:^UIView * _Nonnull{
            return [UIView new];
        }];
        
        /* 设置代理 监听滚动 */
        _managerView.delegate = self;
        
        /* 设置悬停位置 */
        //        _managerView.hoverY = 64;
        
        /* 点击切换滚动过程动画 */
        _managerView.isClickScrollAnimation = YES;
        
        /* 代码设置滚动到第几个位置 */
        [_managerView scrollToIndexWithIndex:_type];
    }
    return _managerView;
}


-(void)glt_scrollViewOffsetY:(CGFloat)offsetY {
    NSLog(@"---> %lf", offsetY);
}


- (NSArray <NSString *> *)titles {
    if (!_titles) {
        _titles = @[@"全部", @"待付款", @"待发货", @"待收货",@"已完成"];
    }
    return _titles;
}

-(NSArray <UIViewController *> *)viewControllers {
    if (!_viewControllers) {
        _viewControllers = [self setupViewControllers];
    }
    return _viewControllers;
}


-(LTLayout *)layout {
    if (!_layout) {
        _layout = [[LTLayout alloc] init];
        _layout.isAverage = YES;
        _layout.sliderWidth = 50;
        _layout.titleViewBgColor = kColorWithRGB(255, 255, 255);
        _layout.titleColor = kColorWithRGB(51, 51, 51);
        _layout.titleSelectColor = kColorWithRGB(0, 0, 0);
        _layout.bottomLineColor = kColorMainTheme;
        _layout.titleFont = [UIFont systemFontOfSize:13];
    }
    return _layout;
}

-(NSArray <UIViewController *> *)setupViewControllers {
    NSMutableArray <UIViewController *> *testVCS = [NSMutableArray arrayWithCapacity:0];
    [self.titles enumerateObjectsUsingBlock:^(NSString * _Nonnull obj, NSUInteger index, BOOL * _Nonnull stop) {
        HGOrderListVC *testVC = [[HGOrderListVC alloc] init];
        testVC.type = index+1;
        [testVCS addObject:testVC];
    }];
    return testVCS.copy;
}




@end
